<template>
	<view class="con-item" :key="form.templateContentId" :id="'r' + form.templateContentId">
		<!-- 标题介绍说明 -->
		<view class="con-item-title">
			<text>{{ formData.locationTypeName == '任务追踪' ? '打卡签字' : formData.name }}</text>
			<text style="color: #999;" v-if="formData.recordData.type == 2 && formData.recordData.min">(最少填{{
				formData.recordData.min }}项)</text>
			<text style="color: #999;" v-if="formData.recordData.type == 3 && formData.recordData.min">(最少{{
				formData.recordData.min }}张)</text>
			<text style="color: #999;" v-if="formData.recordData.type == 4 && formData.recordData.min">(最少{{
				formData.recordData.min }}个)</text>

			<div class="hide-btn" v-if="formData.requireImg && formData.requireImg.length"
				@click="hideRequireImg = !hideRequireImg">{{ hideRequireImg ? '查看指引' : '收起指引' }}</div>
		</view>

		<view v-if="formData.requireImg && formData.requireImg.length && !hideRequireImg" style="position: relative;"
			class="indent">

			<swiper indicator-color="#CCCCCC" indicator-active-color="#0091FF" class="swiper" circular
				:indicator-dots="true" :autoplay="false" :duration="300"
				style="width: 520rpx;height: 766rpx;margin-top: 20rpx;">
				<swiper-item v-for="(item, index) in formData.requireImg" :key="index">
					<image :src="item.url" :mode="'scaleToFill'" :lazy-load="true"
						style="width: 520rpx;height: 694rpx;" />
				</swiper-item>
			</swiper>
		</view>
		<view class="con-item-introduce indent"
			:style="formData.requireImg && formData.requireImg.length && !hideRequireImg ? 'margin-top: -20rpx;' : ''">
			{{
				form.requireDesc || "" }}</view>
		<!-- 标题介绍说明end -->
		<!-- 作业指引 -->
		<view class="guidelines indent">
			<view class="guidelines-item" @click="preViewVideo(item.guideData)"
				v-for="(item, index) in formData.checkGuideList" :key="index">
				<image src="@/static/images/maintain/play.png" mode=""></image>
				<text>作业指引:</text>
				<text class="guidelines-item-name">{{ item.name }}</text>
				<uni-icons color="#9c9c9c" size="16" type="forward"></uni-icons>
			</view>
		</view>
		<!-- 作业指引end -->
		<!-- 题型1 单选 -->
		<view class="content-item indent" v-if="formData.recordData.type == 1">
			<view class="tag-list" v-if="formData.recordData.options.length">
				<view :class="[
					'tag-item',
					formData.recordData.userChoose === index
						? ['success', 'danger', 'routine'][item.result - 1]
						: '',
				]" @click="chooseStatus(item, index)" v-if="!item.hidden" v-for="(item, index) in formData.recordData.options"
					:key="index">
					<uni-icons :color="formData.recordData.userChoose === index
						? ['#6BC013', '#E02020', '#F7B500'][item.result - 1]
						: '#333'
						" size="18" v-if="item.result == 1" style="margin-right: 10rpx" type="checkmarkempty"></uni-icons>

					<uni-icons :color="formData.recordData.userChoose === index
						? ['#6BC013', '#E02020', '#F7B500'][item.result - 1]
						: '#333'
						" size="18" v-if="item.result == 2" style="margin-right: 10rpx" type="closeempty"></uni-icons>
					<text :style="{
						padding: '1rpx 16rpx 0 10rpx',
						color:
							formData.recordData.userChoose === index
								? ['#6BC013', '#E02020', '#F7B500'][item.result - 1]
								: '#333',
					}" v-if="item.result == 3 || item.result == ''" class="ticon">
						―
					</text>
					{{ item.name }}
				</view>
			</view>
			<view class="record-add-btn" @click="addRecord" v-if="showAdd && !comparison && !disabled"
				v-show="planStatus <= 3">
				<uni-icons color="#0091FF" style="margin-right: 6rpx" type="plus"></uni-icons>
				{{ formData.recordData.userData ? (formData.recordData.userData.recordName || '添加保养记录') : '添加保养记录' }}
				<text v-if="formData.recordData.userData &&
					(formData.recordData.userData.files.must ||
						formData.recordData.userData.records.must ||
						formData.recordData.userData.remarks.must)
				" style="color: red">
					*
				</text>
			</view>
			<view style="display: flex;" v-if="comparison && !disabled" v-show="before || after">

				<view class="record-add-btn" @click="addRecord({ status: 'Before' })" v-if="before && !disabled"
					style="margin-right: 40rpx;">
					<uni-icons color="#0091FF" style="margin-right: 6rpx" type="plus"></uni-icons>
					{{ formData.recordData.userData ? formData.recordData.userData.beforeName : '添加保养前记录' }}
					<text v-if="formData.recordData.userData &&
						(formData.recordData.userData.filesBefore.must ||
							formData.recordData.userData.recordsBefore.must ||
							formData.recordData.userData.remarksBefore.must)
					" style="color: red">
						*
					</text>
				</view>

				<view class="record-add-btn" @click="addRecord({ status: 'After' })" v-if="after && !disabled">
					<uni-icons color="#0091FF" style="margin-right: 6rpx" type="plus"></uni-icons>
					{{ formData.recordData.userData ? formData.recordData.userData.afterName : '添加保养后记录' }}
					<text v-if="formData.recordData.userData &&
						(formData.recordData.userData.filesAfter.must ||
							formData.recordData.userData.recordsAfter.must ||
							formData.recordData.userData.remarksAfter.must)
					" style="color: red">
						*
					</text>
				</view>

			</view>

			<!-- 记录数据列表 -->
			<recordView type="1" :isCorrection="true" @addRecord="addRecord($event)" :edit="formData.edit"
				:disabled="disabled" :isPlanStatus="isPlanStatus" :userRecordVOS="formData.userRecordVOS"
				:userinfo="userinfo" :planStatus="planStatus"></recordView>

		</view>
		<!-- 题型1 单选 end -->

		<!-- 题型2 填空题 -->
		<view class="content-item indent" v-if="formData.recordData.type == 2">
			<view class="content-item" v-for="(item, index) in formData.recordData.options" :key="index">
				<view class="name">{{ item.name }}</view>
				<view class="input">
					<view class="input-view" v-if="planStatus == 3 && isPlanStatus">
						<input @blur="bindInputFinish" @input="bindInputChange($event, item)" type="text"
							v-model="item.val" placeholder-style="color:#ccc"
							:placeholder="item.placeholder ? item.placeholderText : ' '" :disabled="disabled" />
						<view class="input-unit" v-if="item.unit">
							{{ item.unitText || "" }}
							<text v-if="item.min !== ''">(正常范围:</text>
							<text v-if="item.min !== ''" style="color: #0091ff">{{ item.min }}-{{ item.max }} {{
								item.unitText || ""
							}}</text>
							<text v-if="item.min !== ''">)</text>
						</view>
					</view>
					<view class="text" v-else>
						<text>{{ item.val || item.placeholderText || "" }}</text>
						<text v-if="item.unit">{{ item.unitText || "" }}</text>
					</view>
				</view>

				<!-- 范围内 -->
				<view style="display: flex;"
					v-if="item.inRangeSet && planStatus <= 3 && item.val !== '' && item.inRanges.comparison && !disabled">

					<view v-if="!befores[index] && item.val >= Number(item.min) && item.val <= Number(item.max)"
						class="record-add-btn"
						@click="addRecord({ obj: item.inRanges, index, status: 'Before', type: 'in' })"
						style="margin-right: 40rpx;">
						<uni-icons color="#0091FF" style="margin-right: 6rpx" type="plus"></uni-icons>
						{{ item.inRanges.beforeName }}
						<text v-if="(item.inRanges.filesBefore.must ||
							item.inRanges.recordsBefore.must ||
							item.inRanges.remarksBefore.must)
						" style="color: red">
							*
						</text>

					</view>

					<view v-if="!afters[index] && item.val >= Number(item.min) && item.val <= Number(item.max)"
						class="record-add-btn"
						@click="addRecord({ obj: item.inRanges, index, status: 'After', type: 'in' })">
						<uni-icons color="#0091FF" style="margin-right: 6rpx" type="plus"></uni-icons>
						{{ item.inRanges.afterName }}
						<text v-if="(item.inRanges.filesAfter.must ||
							item.inRanges.recordsAfter.must ||
							item.inRanges.remarksAfter.must)
						" style="color: red">
							*
						</text>
					</view>
				</view>

				<!-- 范围外 -->
				<view style="display: flex;"
					v-if="item.outRangeSet && planStatus <= 3 && item.val !== '' && item.outRanges.comparison && !disabled">

					<view class="record-add-btn"
						@click="addRecord({ obj: item.outRanges, index, status: 'Before', type: 'out' })"
						:style="{ marginRight: '40rpx', display: (!befores[index] && (item.val < Number(item.min) || item.val > Number(item.max))) ? 'flex' : 'none' }">
						<uni-icons color="#0091FF" style="margin-right: 6rpx" type="plus"></uni-icons>
						{{ item.outRanges.beforeName }}
						<text v-if="(item.outRanges.filesBefore.must ||
							item.outRanges.recordsBefore.must ||
							item.outRanges.remarksBefore.must)
						" style="color: red">
							*
						</text>
					</view>

					<view class="record-add-btn"
						@click="addRecord({ obj: item.outRanges, index, status: 'After', type: 'out' })"
						:style="{ display: (!afters[index] && (item.val < Number(item.min) || item.val > Number(item.max))) ? 'flex' : 'none' }">
						<uni-icons color="#0091FF" style="margin-right: 6rpx" type="plus"></uni-icons>
						{{ item.outRanges.afterName }}
						<text v-if="(item.outRanges.filesAfter.must ||
							item.outRanges.recordsAfter.must ||
							item.outRanges.remarksAfter.must)
						" style="color: red">
							*
						</text>
					</view>
				</view>
				<view class="" v-show="planStatus <= 3 && item.val !== '' && item.inRangeSet && item.in && !item.inRanges.comparison
					&& !disabled">
					<view class="record-add-btn" @click="addRecord({ obj: item.inRanges, index, type: 'in' })"
						:style="{ display: (item.val >= Number(item.min) && item.val <= Number(item.max)) ? 'flex' : 'none' }">
						<uni-icons color="#0091FF" style="margin-right: 6rpx" type="plus"></uni-icons>
						{{ item.inRanges.recordName || '保养记录' }}(范围内)
						<text v-if="(item.inRanges.files.must ||
							item.inRanges.records.must ||
							item.inRanges.remarks.must)
						" style="color: red">
							*
						</text>
					</view>
				</view>
				<view class="" v-show="planStatus <= 3 && item.val !== '' && item.outRangeSet && item.out && !item.outRanges.comparison
					&& !disabled">
					<view class="record-add-btn" @click="addRecord({ obj: item.outRanges, index, type: 'out' })"
						:style="{ display: (item.val < Number(item.min) || item.val > Number(item.max)) ? 'flex' : 'none' }">
						<uni-icons color="#0091FF" style="margin-right: 6rpx" type="plus"></uni-icons>
						{{ item.outRanges.recordName || '保养记录' }}(范围外)
						<text v-if="(item.outRanges.files.must ||
							item.outRanges.records.must ||
							item.outRanges.remarks.must)
						" style="color: red">
							*
						</text>
					</view>
				</view>

				<recordView type="2" :isCorrection="true" @addRecord="addRecord($event)" :edit="formData.edit"
					:disabled="disabled" :isPlanStatus="isPlanStatus" :userRecordVOS="formData['userRecordVOS' + index]"
					:userinfo="userinfo" :planStatus="planStatus">
				</recordView>

				<view class="line" v-if="index != formData.recordData.options.length - 1"></view>
			</view>
		</view>
		<!-- 题型2 填空题 end -->

		<!-- 题型3 图片/视频题 -->
		<view class="content-item indent" v-if="formData.recordData.type == 3 || formData.recordData.type == 4">

			<view class="files">
				<view :class="['files-item']" v-for="(item, index) in formData.recordData.val" :key="index">
					<image @click="preViewFile(formData.recordData.val, index)" :lazy-load="true" :src="item.type == 'image'
						? item.url
						: item.img || '/static/images/video.png'
						" mode="aspectFill"></image>
					<view class="remove"
						v-if="planStatus == 3 && (userinfo.user_id == item.userId || !item.userId) && !disabled"
						@click.stop="removeImg(index)">-</view>
					<!-- ai合规情况结论 S -->
					<view v-if="item.modelId && item.aiResult != undefined"
						:class="['ai-result', ['gre', 'org', 'red'][item.aiResult == -1 ? 2 : item.aiResult]]"
						@click.stop="preViewFile(formData.recordData.val, index)">
						<image class="ai-result-ico" src="@/static/images/ai.svg"></image>
						<text>
							{{ item.aiResult == -1 ? '无法识别' : ['合规', '疑似合规', '不合规'][item.aiResult] }}
						</text>
					</view>
					<!-- ai合规情况结论 E -->
				</view>
				<view class="files-item add" style="line-height: 32rpx;" @click="addImg"
					v-if="planStatus == 3 && !disabled">
					<image
						:src="formData.recordData.type == 3 ? '/static/images/camera.png' : '/static/images/vicon.png'"
						mode="">
					</image>
					<view class="text">{{ formData.recordData.type == 3 ? "上传图片" : "上传视频" }}</view>
				</view>
			</view>

			<view class="record-add-btn" @click="addRecord" v-if="formData.recordData.options.result && !disabled"
				:style="{ display: (planStatus == 3 && !formData.recordData.options.comparison) ? 'flex' : 'none' }">
				<uni-icons color="#0091FF" style="margin-right: 6rpx" type="plus"></uni-icons>
				{{ formData.recordData.options.recordName || '保养记录' }}
			</view>

			<view style="display: flex;"
				v-if="formData.recordData.options.result && formData.recordData.options.comparison"
				v-show="planStatus == 3">
				<view style="margin-right: 40rpx;" v-if="before && !disabled" class="record-add-btn"
					@click="addRecord({ status: 'Before' })">
					<uni-icons color="#0091FF" style="margin-right: 6rpx" type="plus"></uni-icons>
					{{ formData.recordData.options.beforeName }}
					<text v-if="(formData.recordData.options.filesBefore.must ||
						formData.recordData.options.recordsBefore.must ||
						formData.recordData.options.remarksBefore.must)
					" style="color: red">
						*
					</text>
				</view>

				<view class="record-add-btn" v-if="after && !disabled" @click="addRecord({ status: 'After' })">
					<uni-icons color="#0091FF" style="margin-right: 6rpx" type="plus"></uni-icons>
					{{ formData.recordData.options.afterName }}
					<text v-if="(formData.recordData.options.filesAfter.must ||
						formData.recordData.options.recordsAfter.must ||
						formData.recordData.options.remarksAfter.must)
					" style="color: red">
						*
					</text>
				</view>
			</view>

			<recordView type="3" :isCorrection="true" @addRecord="addRecord($event)" :edit="formData.edit"
				:disabled="disabled" :isPlanStatus="isPlanStatus" :userRecordVOS="formData.userRecordVOS"
				:userinfo="userinfo" :planStatus="planStatus"></recordView>

		</view>
		<!-- 题型3 图片/视频题 end -->

		<!-- 评分记录 -->
		<view class="content-logs"
			v-if="form.byWorkScoreInfoVos && form.byWorkScoreInfoVos.length > 0 && (alidPlan || form.byWorkScoreInfoVos.questionDesc)">
			<view class="title">评分记录</view>
			<view class="logs_box" v-if="alidPlan">
				<view class="label" style="width:auto;">{{ form.byWorkScoreInfoVos[0].dimensionName }}:</view>
				<view class="msg">{{ form.byWorkScoreInfoVos[0].scoreLevel }}</view>
			</view>
			<view class="logs_box" v-if="alidPlan">
				<view class="label">得分:</view>
				<view class="msg">{{ form.byWorkScoreInfoVos[0].checkScore || '--' }}</view>
			</view>
			<view class="logs_box" v-if="alidPlan && form.byWorkScoreInfoVos[0].scoreDesc">
				<view class="label">备注:</view>
				<view class="msg">{{ form.byWorkScoreInfoVos[0].scoreDesc || '--' }}</view>
			</view>
			<view class="logs_box" v-if="form.byWorkScoreInfoVos[0].questionDesc">
				<view class="label">问题:</view>
				<view class="msg">{{ form.byWorkScoreInfoVos[0].questionDesc || '--' }}</view>
			</view>
			<view class="logs_box">
				<view class="label">时间:</view>
				<view class="msg">{{ form.byWorkScoreInfoVos[0].createTime }}</view>
			</view>
			<view class="content-logsTitle" v-if="form.byWorkScoreInfoVos.some((it) => it.childPlanId)">关联任务</view>
			<block v-for="(pro, index) in form.byWorkScoreInfoVos" :key="index">
				<view class="content-logs-plan" v-if="pro.childPlanId">
					<!--  <view class="content-logs-plan-title" v-if="index === 0">关联任务</view> -->
					<view class="content-logs-plan-card">
						<view class="clpc-item">
							<view class="clpc-item-label">关联任务:</view>
							<view class="clpc-item-content">{{ pro.childPlanId }} <text class="tag">{{ ['保养', '维修',
								'配件', '事务', '事务'][pro.childTypeStatus - 1] }}</text></view>
						</view>
						<view class="clpc-item">
							<view class="clpc-item-label">任务状态:</view>
							<view class="clpc-item-content"><text style="color:#0DCAA0">{{
								(affairStatus[pro.childPlanStatus ||
									2]).name }}</text></view>
						</view>
					</view>
					<view class="content-logs-plan-view" @click="toAffair(pro)">查看</view>
				</view>
			</block>
		</view>
		<!-- <view class="line"></view> -->
	</view>
</template>

<script>
import recordView from './record.vue';
import { mapState } from 'vuex';
import { setWatermarkJson, setPath, getWaterMarkInfo } from '@/utils/watermarkTool.js';
import { MODEL_ID_MAP,getModelType } from '@/utils/constants.js';
import sidaAI from '@/utils/ai';
import md5 from 'js-md5';

export default {
	components: { recordView },
	props: {
		pictureDisable: [String, Number],
		tltId: [String, Number],
		planId: [String, Number],
		planStatus: [String, Number],
		isPlanStatus: {
			type: Boolean,
			default: false,
		},
		idx: {
			type: [String, Number],
		},
		form: {
			type: Object,
			default() {
				return {};
			},
		},
		disabled: {
			type: Boolean,
			default: false,
		}
	},
	data() {
		return {
			affairStatus: {
				2: {
					status: 2,
					name: '待开始',
					icon: '../../static/images/step1.png',
					createTime: '',
				},
				3: {
					status: 3,
					name: '进行中',
					icon: '../../static/images/step2.png',
					createTime: '',
				},
				4: {
					status: 4,
					name: '已完成',
					icon: '../../static/images/step3.png',
					createTime: '',
				}
			},
			hideRequireImg: false,// 收起指引图片
			comparison: false,
			before: false,// 显示保养前
			after: false,// 显示保养后按钮
			normals: {},
			befores: {},// 保养前 填空题
			afters: {},// 保养后 填空题
			loading: false, // 是否请求中
			formData: {
				edit: false,
				checkDesc: '',
				imgUrl: '',
				videoUrl: '',
				recordData: {},
				record: '',

				userRecordVOS: [],
				userData: {},
			},
			showAdd: false,
			finish: false, // 工作项是否已完成
			showTips: false, // 是否显示未完成提示
		};
	},
	computed: {
		...mapState('user', ['userinfo']),
		...mapState('system', ['onlineStatus']),
		alidPlan() {
			if (this.$root.planDetail && this.$root.planDetail.maintainPlanContentExt && this.$root.planDetail.maintainPlanContentExt.scoreType == 1) {
				return true;
			} else {
				return false;
			}
		}

	},
	watch: {
		form: {
			handler(new_value, old_value) {
				this.showTips = false;
				this.initData(new_value);
				console.log('form', new_value);
			},
		},
		pictureDisable() {
			this.hideRequireImg = this.pictureDisable == 1 ? true : false;
		},
		finish(res) { },
	},
	created() {
		this.hideRequireImg = this.pictureDisable == 1 ? true : false;
		this.initData();

		if (this.form.recordData && this.form.recordData.type == 1) {
			uni.$on('Check' + this.planId, (res) => {
				if (!res || !res.ids || res.ids.indexOf(this.formData.childPlanCheckHistoryId) == -1) {
					return;
				}

				if (res.allChecked === true) {
					this.formData.recordData.userChoose = 0;
					this.formData.recordData.userData = JSON.parse(
						JSON.stringify(this.formData.recordData.options[0])
					);
				} else {
					delete this.formData.recordData.userChoose;
					delete this.formData.recordData.userData;
				}

				this.setshowAdd();
				this.setFinishStatus();
			});
			uni.$on('setFinishStatus' + this.planId, () => {
				this.initData();
			});
		}
	},
	mounted() {
		// #ifdef H5 
		this.$emit('setNode', {
			planId: this.planId,
			templateContentId: this.form.templateContentId,
			node: this
		});
		// #endif

		// #ifdef MP-WEIXIN 
		uni.$emit('setNode' + this.planId, {
			planId: this.planId,
			templateContentId: this.form.templateContentId,
			node: this
		});
		// #endif
	},
	beforeDestroy() {
	},
	methods: {
		// 查看详情
		toAffair(item) {
			if (item.childTypeStatus === 2) {
				uni.navigateTo({
					url: `/subpages/repair/repariDetail?planId=${item.childPlanId}&elevatorId=${this.$root.elevatorId}`,
				});
			}
			if (item.childTypeStatus === 5) {
				uni.navigateTo({
					url: `/subpages/repair/affair/affairDetail?planId=${item.childPlanId}&elevatorId=${this.$root.elevatorId}`,
				});
			}
		},

		watchFinish(os) {
			let that = this;
			let fns = that.finish;
	
			if (fns) {
				return;
			}
			that.showTips = true;
			this.$emit('setShowTips', {
				finish: fns,
				showTips: this.showTips
			});

			if (os.view) {
				return;
			}

			let query = that.createSelectorQuery(); // 创建节点查询器
			query.select('#r' + that.form.templateContentId).boundingClientRect(); // 选择id为comment的节点并查询的它布局位置
			query.exec((res) => {
				// 执行请求
				// console.log('toComment', this.formData.name, this.finish, res);
				uni.$emit('scrollToView', {
					...res,
					workitem: that.formData,
					finish: fns,
				});
			});
		},
		initData(data = null) {
			let val = data || this.form;
			if (val.recordData.type == 1 && val.userRecordVOS) {
				if (!val.recordData.userData && val.recordData.options) {
					// 如果没有选中 查询一下默认选中
					for (let i = 0; i < val.recordData.options.length; i++) {
						if (val.recordData.options[i].default) {
							val.recordData.userData = val.recordData.options[i];
							val.recordData.userChoose = i;
							break;
						}
					}
				}
			}
			if (val.recordData.type == 2) {
				for (var i = 0; i < val.recordData.options.length; i++) {
					if (val.recordData.options[i].val) {
					} else {
						val.recordData.options[i].val = '';
					}
					val['userRecordVOS' + i] = {};
				}

				let map = {};
				if (val.userRecordVOS) {
					// 多项填空题
					for (let i = 0; i < val.userRecordVOS.length; i++) {
						val.userRecordVOS[i].recordVOList =
							val.userRecordVOS[i].recordVOList.sort((a, b) => {
								return a.updateTime > b.updateTime ? -1 : 1;
							});

						for (let j = 0; j < val.userRecordVOS[i].recordVOList.length; j++) {
							let idx =
								val.userRecordVOS[i].recordVOList[j].recordDataValue.index;
							if (idx || idx === 0) {
								if (val['userRecordVOS' + idx][val.userRecordVOS[i].userId]) {
									val['userRecordVOS' + idx][
										val.userRecordVOS[i].userId
									].list.push(val.userRecordVOS[i].recordVOList[j]);
								} else {
									val['userRecordVOS' + idx][val.userRecordVOS[i].userId] = {
										name: val.userRecordVOS[i].userName,
										list: [val.userRecordVOS[i].recordVOList[j]],
									};
								}
							}
						}
					}

					for (let i = 0; i < val.recordData.options.length; i++) {
						// val.recordData.options[i]
						val.recordData.options[i].in = true;
						val.recordData.options[i].out = true;
						if (
							!val['userRecordVOS' + i] ||
							!val['userRecordVOS' + i][this.userinfo.user_id]
						) {
						} else {
							if (
								val['userRecordVOS' + i][this.userinfo.user_id].list[0]
									.recordDataValue.type == 'in'
							) {
								val.recordData.options[i].in = false;
							} else if (
								val['userRecordVOS' + i][this.userinfo.user_id].list[0]
									.recordDataValue.type == 'out'
							) {
								val.recordData.options[i].out = false;
							}
						}
					}
				}
			}
			if (val.recordData.type == 3 || val.recordData.type == 4) {
				if (val.userRecordVOS) {
					for (let i = 0; i < val.userRecordVOS.length; i++) {
						val.userRecordVOS[i].recordVOList =
							val.userRecordVOS[i].recordVOList.sort((a, b) => {
								return a.updateTime > b.updateTime ? -1 : 1;
							});
					}
				}

				val.recordData.val = val.recordData.val || [];
			}
			this.formData = {
				...val,
				edit: this.form.edit ? true : false,
			};
			// this.finish = this.formData.finish ? true : false//是否已完成
			this.setshowAdd();

			this.setFinishStatus();
		},
		// 填空题失去焦点监听
		bindInputFinish(res) {
			this.workItemUpdate();
		},
		// 填空题输入监听
		bindInputChange(val, item) {
			this.setshowAdd();
		},
		setshowAdd() {
			const needFuc = (item, key = '') => {// 判断是否需要填写记录
				// console.log(1111, item, key);
				try {
					if (item['files' + key].need || item['records' + key].need || item['remarks' + key].need) {
						return true;
					} else {
						return false;
					}
				} catch (error) {
					return false;
				}
			};
			try {
				if (this.formData.recordData.type == 2) {
					let befores = {};
					let afters = {};
					let normals = {};

					let options = this.formData.recordData.options;
					for (let i = 0; i < options.length; i++) {
						let item = options[i];
						let type = (item.val !== '' && item.inRangeSet && item.val >= Number(item.min) && item.val <= Number(item.max)) ? 'in' : 'out';
						let userRecordVOS = this.formData['userRecordVOS' + i];
						befores[i] = !needFuc(item[type + 'Ranges'], 'Before');
						afters[i] = !needFuc(item[type + 'Ranges'], 'After');
						normals[i] = !needFuc(item[type + 'Ranges'], '');

						for (const key in userRecordVOS) {
							if (key == this.userinfo.user_id) {
								let list = userRecordVOS[key].list;
								let beforeItem = {};
								let afterItem = {};
								let normalItem = {};
								for (let j = 0; j < list.length; j++) {
									if (list[j].status == 2 && !beforeItem.id && list[j].recordDataValue.type == type) {
										befores[list[j].recordDataValue.index] = true;
										beforeItem = list[j];
									}

									if (list[j].status == 3 && !afterItem.id && list[j].recordDataValue.type == type) {
										afters[list[j].recordDataValue.index] = true;
										afterItem = list[j];
									}

									if (list[j].status == 1 && !normalItem.id && list[j].recordDataValue.type == type) {
										normals[list[j].recordDataValue.index] = true;
										normalItem = list[j];
									}
								}
							}
						}
					}

					this.normals = normals;
					this.befores = befores;
					this.afters = afters;
				}

				if (this.formData.recordData.type == 1 || this.formData.recordData.type == 3 || this.formData.recordData.type == 4) {
					if (this.formData.recordData.userData) {
						this.before = true;
						this.after = true;
					} else {
						this.before = false;
						this.after = false;
					}

					// 题型1
					if (this.formData.userRecordVOS) {
						// 对用户操作记录进行标记，判断是否符合选择的结果
						for (let i = 0; i < this.formData.userRecordVOS.length; i++) {
							if (
								this.formData.userRecordVOS[i].userId ==
								this.userinfo.user_id &&
								(this.formData.recordData.userData || this.formData.recordData.type == 3 || this.formData.recordData.type == 4)
							) {
								if (this.formData.recordData.type == 1) {
									if (
										this.formData.recordData.userData.result ==
										this.formData.userRecordVOS[i].recordVOList[0].recordDataValue
											.result
									) {
										this.formData.userRecordVOS[i].showAdd = false;
									} else {
										this.formData.userRecordVOS[i].showAdd = true;
									}
								}

								// 判断是否有保养前后数据 
								for (let j = 0; j < this.formData.userRecordVOS[i].recordVOList.length; j++) {
									if (this.formData.userRecordVOS[i].recordVOList[j].status == 2) {
										this.before = false;
									}
									if (this.formData.userRecordVOS[i].recordVOList[j].status == 3) {
										this.after = false;
									}
								}
							} else {
								this.formData.userRecordVOS[i].showAdd = false;
							}
						}
					}

					if (this.formData.recordData.type == 1) {
						let arr = this.formData.userRecordVOS || [];
						let idx = arr.findIndex((item) => {
							return item.userId == this.userinfo.user_id && !item.showAdd;
						});
						if (idx != -1) {
							this.showAdd = false;
						} else {
							if (
								this.formData.recordData.userData &&
								(this.formData.recordData.userData.files.need || this.formData.recordData.userData.records.need || this.formData.recordData.userData.remarks.need)
							) {
								this.showAdd = true;
							} else {
								this.showAdd = false;
							}
						}

						if (this.formData.recordData.userData) {
							this.comparison = this.formData.recordData.userData.comparison || false;
						}
					} else {
						// 图片或视频
						if (this.formData.recordData.options.comparison) {
							this.before = true;
							this.after = true;
							// 保养前后
							let arr = this.formData.userRecordVOS || [];
							let idx = arr.findIndex((item) => {
								return item.userId == this.userinfo.user_id;
							});
							if (idx != -1) {
								const records = arr[idx].recordVOList || [];
								for (let j = 0; j < records.length; j++) {
									if (records[j].status == 2) {
										this.before = false;
									}
									if (records[j].status == 3) {
										this.after = false;
									}
								}
							}
						}
					}
				}
			} catch (err) {
				console.log('conitem-820', err);
			}
		},
		// 预览
		preViewFile(list, index) {
			this.$previewMedia({
				sources: list,
				current: index,
			});
		},
		// 添加描述记录
		addRecord({ obj = {}, index, type, status }) {
			if (this.planStatus > 3) {
				return;
			}
			if (this.planStatus != 3 || !this.isPlanStatus) {
				this.toosTipFalse();
				return;
			}
			let recordForm = {};

			if (obj.records) {  // 编辑 
				recordForm = JSON.parse(JSON.stringify(obj));
				if (this.formData.recordData.type == 2) {
					if (index || index === 0) {
						recordForm.index = index; // 多项填空时记录是哪一项
					}
					if (status) {
						recordForm.comparisonType = status;
					}

					recordForm.type = recordForm.type || type;
				}
			} else {
				if (this.formData.recordData.type == 1) {  // 单选
					recordForm = this.formData.recordData.userData;
					if (status) {
						recordForm.comparisonType = status;// 添加保养前或保养后
					}
				}
				if (this.formData.recordData.type == 2) {
					recordForm.index = index;
					recordForm.comparisonType = status;
				}
				if (this.formData.recordData.type == 3) {
					recordForm = JSON.parse(
						JSON.stringify(this.formData.recordData.options)
					);
					recordForm.comparisonType = status;
				}
				if (this.formData.recordData.type == 4) {
					recordForm = JSON.parse(
						JSON.stringify(this.formData.recordData.options)
					);
					recordForm.comparisonType = status;
				}
			}
			recordForm.templateContentId = this.formData.templateContentId;
			recordForm.checkHistoryId = this.formData.childPlanCheckHistoryId;
			recordForm.templateContentName = this.formData.name;
			recordForm.locationIds = this.formData.tltIds;
			recordForm.locationNames = this.formData.tltNames;
			recordForm.templateId = this.formData.templateId;
			recordForm.templateName = this.formData.templateName;

			this.$emit('addrecord', recordForm);
			console.log('addrecord-done');
		},
		toosTipFalse(str) {
			// uni.showModal({
			// 	title: '提示',
			// 	content: str || '请先签到开始再编辑保养记录',
			// 	showCancel: false
			// });
			uni.showToast({
				title: str || '请开始签到，再保养记录',
				icon: 'none',
				mask: true,
			});
		},
		// 检查该工作项是否完成
		setFinishStatus() {
			let finish = true;
			if (this.$root.setFinishStatus) {// 根组件校验方法（保养整改详情页）
				finish = this.$root.setFinishStatus(this.formData);
			} else {
				finish = false;
			}

			console.log('校验是否已完成', this.formData.name, finish, this.tltId, this.formData);

			this.$set(this, 'finish', finish);

			this.$forceUpdate();
			uni.$emit('workitemStatusUpdate' + this.planId, {
				templateId: this.formData.templateId,
				id: this.formData.templateContentId,
				checkHistoryId: this.formData.childPlanCheckHistoryId,
				tltId: this.tltId,
				userChoose: this.formData.recordData.userChoose,
				finished: finish
			});
			this.$emit('finish', {
				tltId: this.tltId,
				id: this.formData.templateContentId,
				checkHistoryId: this.formData.childPlanCheckHistoryId,
				finish,
				userChoose: this.formData.recordData.userChoose,
			});
			return finish;
		},
		// 提交工作项数据
		workItemUpdate() {
			if (this.disabled) return;
			// 检查该工作项是否完成 
			const params = { ...this.formData, planId: this.planId };
			console.log(`[workOrders/detail.vue] workitemUpdate${this.planId} params size:${JSON.stringify(params).length}`);
			uni.$emit('workitemUpdate' + this.planId, params);
		},
		// 题型1选择某一项
		chooseStatus(item, index) {
			if (this.disabled) return;
			if (this.planStatus > 3) {
				return;
			}
			if (this.planStatus != 3 || !this.isPlanStatus) {
				this.toosTipFalse();
				return;
			}
			if (this.loading) {
				uni.showToast({
					title: '您的操作太快了，请稍后',
					icon: 'none',
				});
				return;
			}
			if (
				this.formData.recordData.userChoose === undefined ||
				index != this.formData.recordData.userChoose
			) {
				this.formData.recordData.userChoose = index;
				this.formData.recordData.userData = item;
			} else {
				delete this.formData.recordData.userChoose;
				delete this.formData.recordData.userData;

				for (let i = 0; i < this.formData.recordData.options.length; i++) {
					if (this.formData.recordData.options[i].default) {
						this.formData.recordData.userData = this.formData.recordData.options[i];
						this.formData.recordData.userChoose = i;
						break;
					}
				}
			}

			this.setshowAdd();
			this.workItemUpdate();
			this.$forceUpdate();
		},

		removeImg(idx) {
			if (this.planStatus != 3 || !this.isPlanStatus) {
				this.toosTipFalse();
				return;
			}

			uni.showModal({
				title: '提示',
				content: '是否删除?',
				success: async (res) => {
					if (res.confirm) {
						uni.showLoading({
							title: '提交中',
							mask: true,
						});
						let data = this.formData.recordData.val || [];
						data.splice(idx, 1);
						this.formData.imgUrl = data;
						this.workItemUpdate();
						uni.hideLoading();
					}
				},
			});
		},
		addImg() {
			if (this.planStatus >= 4) {
				return;
			}
			if (this.planStatus != 3 || !this.isPlanStatus) {
				this.toosTipFalse();
				return;
			}
			if (
				this.formData.recordData.max &&
				this.formData.recordData.max <= this.formData.recordData.val.length
			) {
				uni.showToast({
					title: '上传数量已达上限',
					icon: 'none',
				});
				return;
			}

			if (
				this.formData.recordData.val.length >= this.formData.recordData.max &&
				this.formData.recordData.max > 0
			) {
				uni.showToast({
					title: `照片最多可上传${this.formData.recordData.max}张`,
					icon: 'none',
				});
				return;
			}
			let _this = this;

			if (this.formData.recordData.type == 3) {
				// 查看这个工作项拍照是否需要模型 
				let modelType = getModelType(this.form.templateContentId);

				// modelType = '1';
				// 模型识别结果
				let aiResult = '';
				// 模型Id
				let modelId = '';

				const cameraImag = async () => {
					try {
						uni.$off('uploadImg'); // 先清除事件，防止重复
					} catch (error) {
						console.log('error', error);
					}
					uni.$once('uploadImg', async (path, imgId, options) => {
						uni.showLoading({
							title: '上传中',
							mask: true
						});

						let watermark = await getWaterMarkInfo();

						const parseJsonSafely = (jsonString) => {
							if (!jsonString) {
								return {};
							}
							if (typeof jsonString == 'object') {
								return jsonString;
							}
							let jso = null;
							try {
								jso = JSON.parse(jsonString);
							} catch (error) {
								console.error('解析 JSON 失败:', error);
							}
							return jso;
						};

						const opt = parseJsonSafely(options) || {};

						// #ifdef H5 
						const md5Path = md5(path);
						setPath(md5Path, imgId);
						// #endif

						const obj = {
							imgId,
							modelType,
							planId: this.planId,
							templateId: this.form.templateId,
							templateName: this.form.templateName,
							locationIds: this.form.tltIds,
							locationNames: this.form.tltNames,
							templateContentId: this.form.templateContentId,
							templateContentName: this.form.name,
							type: 3,
							result: '',
							watermark: watermark ? JSON.stringify(watermark) : '',
						};

						// 模型输出结果(modelType有值需要写入模型信息)
						if (modelType && opt.result !== undefined) {
							try {
								aiResult = opt.result;
								modelId = MODEL_ID_MAP[`${modelType}`];

								Object.assign(obj, {
									result: `${opt.result}`,
									model_id: modelId,
									model_result: opt.model_result ? JSON.stringify(opt.model_result) : '',
								});
							} catch (error) {
								console.log(error);
							}
						}

						await this.setWatermarkJson(obj);

						let img = await this.uploadFileFuc(path, imgId);
						if (img == '') return uni.hideLoading();

						_this.formData.recordData.val.push({
							url: img,
							type: 'image',
							userId: this.userinfo.user_id,
							aiResult,
							modelId,
							modelType
						});
						uni.hideLoading();
						_this.$forceUpdate();
						_this.workItemUpdate();
					});

					let pages = getCurrentPages();
					let pag = pages[pages.length - 1];

					let imgId = await setWatermarkJson({
						planId: this.planId,
						modelType,
						templateId: this.form.templateId,
						templateName: this.form.templateName,
						locationIds: this.form.tltIds,
						locationNames: this.form.tltNames,
						templateContentId: this.form.templateContentId,
						templateContentName: this.form.name,
						type: 3
					});

					if (pag.route && pag.route.indexOf('workOrders/detail') != -1) {
						uni.$emit('openCamera', { imgType: 1, imgId, modelType });
					} else {
						uni.navigateTo({
							url: '/pages/camera/camera?imgType=1&imgId=' + imgId + (modelType ? `&modelType=${modelType}` : ''),
							fail: (err) => {
								console.log(err);
							}
						});
					}
				};
				if (this.formData.recordData.options.onlyAlbum) {// 只能拍照
					cameraImag();
				} else {
					// cameraImag();
					// return //去掉相册选择暂时
					uni.showActionSheet({
						itemList: ['拍摄', '从相册选择'],
						success: async (res) => {
							if (res.tapIndex == 0) {
								cameraImag();
							} else if (res.tapIndex == 1) {
								// #ifndef H5
								uni.chooseImage({
									count: this.formData.recordData.max
										? this.formData.recordData.max - this.formData.recordData.val.length
										: 9,
									sizeType: ['original'], // ['original', 'compressed']
									sourceType: ['album'],
									success: async (res) => {
										let files = res.tempFilePaths;

										if (files.length == 0) return;

										uni.showLoading({
											title: '上传中',
											mask: true
										});

										// let watermark = await getWaterMarkInfo();
										let data = _this.formData.recordData.val || [];

										for (let i = 0; i < files.length;) {
											let imgId = '';
											let result = {};
											if (modelType && this.onlineStatus) {
												// 需要跑模型
												// 进行推理
												result = await sidaAI.inferImageMultiModel(modelType, files[i]);
												console.log('推理结果：', result);

												const obj = {
													planId: this.planId,
													modelType,
													// 3-保养工作项内容
													type: 3,
													result: `${result.determine}`,
													model_id: MODEL_ID_MAP[modelType],
													watermark: '',
													model_result: JSON.stringify(result.results),
													templateId: this.form.templateId,
													templateName: this.form.templateName,
													locationIds: this.form.tltIds,
													locationNames: this.form.tltNames,
													templateContentId: this.form.templateContentId,
													templateContentName: this.form.name
												};
												imgId = await this.setWatermarkJson(obj);
											}
											let url = await _this.uploadFileFuc(files[i], imgId);
											if (url) {
												let fileItem = {
													url: url,
													userId: this.userinfo.user_id,
													type: 'image',
												};
												if (modelType) {
													fileItem.aiResult = result.determine;
													fileItem.modelType = modelType;
													fileItem.modelId = MODEL_ID_MAP[modelType];
												}
												data.push(fileItem);
											}
											_this.formData.recordData.val = data;
											i++;
										}
										uni.hideLoading();
										_this.$forceUpdate();
										_this.workItemUpdate();
									},
								});
								// #endif

								// #ifdef H5
								window.sida.chooseImage({
									count: Object.keys(MODEL_ID_MAP).includes(modelType) ? 1 : (this.formData.recordData.max
										? this.formData.recordData.max - this.formData.recordData.val.length
										: 9),
									sizeType: ['original'], // ['original', 'compressed']
									sourceType: ['album'],
									success: async (res) => {
										const files = res.tempFilePaths;

										if (files.length == 0) return;

										uni.showLoading({
											title: '上传中',
											mask: true
										});
										// 获取水印信息（项目名称，时间，位置信息
										let data = _this.formData.recordData.val || [];

										// modelType 1签到模型，2签退模型, 3底坑清洁
										if (Object.keys(MODEL_ID_MAP).includes(`${modelType}`)) {
											// 单张图片, 跑模型
											const processHandler = (data, model) => new Promise((resolve, reject) => {
												window.sida.sidaAI({
													data,
													model,
													success: (res) => resolve(res),
													fail: (err) => reject(err)
												});
											});

											for (let i = 0; i < files.length; i++) {
												try {
													const file = files[i];
													const result = await processHandler(file, `${modelType}`);
													const optionsObj = JSON.parse(result);
													const obj = {
														modelType,
														planId: this.planId,
														templateId: this.form.templateId,
														templateName: this.form.templateName,
														locationIds: this.form.tltIds,
														locationNames: this.form.tltNames,
														templateContentId: this.form.templateContentId,
														templateContentName: this.form.name,
														type: 3,
														result: `${optionsObj.result}`,
														// model_id: modelType === '1' ? '3b4caf46-75a1-44c2-9678-097c403a158c' : '04521863-0472-44be-b159-f3eeb2920916',
														// watermark: JSON.stringify(watermark),
														model_id: MODEL_ID_MAP[`${modelType}`],
														watermark: '',
														model_result: JSON.stringify(optionsObj.model_result),
													};

													const imgId = await this.setWatermarkJson(obj);
													// base
													const md5Path = md5(file);
													setPath(md5Path, imgId);

													let url = await _this.uploadFileFuc(file, imgId);
													if (url) {
														data.push({
															url: url,
															type: 'image',
															userId: this.userinfo.user_id,
															aiResult: `${optionsObj.result}`,
															// modelId: modelType === '1' ? '3b4caf46-75a1-44c2-9678-097c403a158c' : '04521863-0472-44be-b159-f3eeb2920916',
															modelId: MODEL_ID_MAP[`${modelType}`],
														});
													}
													_this.formData.recordData.val = data;
												} catch (error) {
													console.error(`处理第 ${i + 1} 个文件时出错:`, error);
													uni.showToast({
														title: `第 ${i + 1} 个文件处理失败`,
														icon: 'none'
													});
												}
											}
										} else {
											// 多张图片, 不跑模型
											for (let i = 0; i < files.length; i++) {
												let url = await _this.uploadFileFuc(files[i], null);

												if (url) {
													data.push({
														url: url,
														userId: this.userinfo.user_id,
														type: 'image',
													});
												}
												_this.formData.recordData.val = data;
											}
										}

										uni.hideLoading();
										_this.$forceUpdate();
										_this.workItemUpdate();
									},
								});
								// #endif
							}
						},
					});
				}
			} else if (this.formData.recordData.type == 4) {
				uni.showActionSheet({
					itemList: this.formData.recordData.options.onlyAlbum ? ['拍摄'] : ['拍摄', '从相册选择'],
					success: (sheet) => {
						let sourceType = sheet.tapIndex == 0 ? 'camera' : 'album';
						uni.chooseVideo({
							count: 1,
							sizeType: ['compressed'],
							sourceType: [sourceType],
							maxDuration: 30,
							success: async (res) => {
								uni.showLoading({
									title: '上传中',
									mask: true,
								});
								let video = await this.uploadFileFuc(res.tempFilePath);
								let list = _this.formData.recordData.val || [];
								if (video) {
									list.push({
										url: video,
										userId: this.userinfo.user_id,
										type: 'video',
									});
								}

								_this.formData.recordData.val = list;
								uni.hideLoading();
								this.$forceUpdate();
								_this.workItemUpdate();
							},
						});
					},
				});
			}
		},

		// 上传文件
		async uploadFileFuc(file, imgId = '', options) {
			return new Promise(async (resolve) => {
				if (imgId) {
					// 如果有imgid 添加路径关联关系

					// #ifdef H5
					const md5Path = md5(file);
					setPath(md5Path, imgId);
					// #endif

					// #ifndef H5
					setPath(file, imgId);
					// #endif
				} else {
					// 生成imgId
					imgId = await setWatermarkJson({
						planId: this.planId,
						templateId: this.form.templateId,
						templateName: this.form.templateName,
						locationIds: this.form.tltIds,
						locationNames: this.form.tltNames,
						templateContentId: this.form.templateContentId,
						templateContentName: this.form.name,
						type: 3,
						watermark: options && options.watermark ? JSON.stringify(options.watermark) : ''
					});

					// #ifdef H5
					const md5Path = md5(file);
					setPath(md5Path, imgId);
					// #endif

					// #ifndef H5
					setPath(file, imgId);
					// #endif
				}
				if (!this.onlineStatus) {
					// 离线，先放本地原文件
					resolve(file);
					return;
				}

				this.http
					.upload(file, imgId, options)
					.then(res => {
						resolve(res.data.link);
					}).catch(err => {
						uni.showModal({
							title: '上传失败',
							content: `请重新上传, 异常原因：${JSON.stringify(err)}`,
						});
						// uni.showToast({
						//   title: '上传失败',
						//   icon: 'none'
						// })
						resolve('');
					});
			});
		},

		removeVideo(idx) {
			if (!this.formData.edit) {
				return;
			}

			uni.showModal({
				title: '提示',
				content: '是否删除该录像?',
				success: (res) => {
					if (res.confirm) {
						let data = this.formData.videoUrl || [];
						data.splice(idx, 1);
						this.formData.videoUrl = data;
						this.$forceUpdate();
					}
				},
			});
		},

		preViewVideo(url) {
			uni.$emit('preViewVideo', url);
		},
	},
};
</script>

<style lang="scss" scoped>
.con-item {
	// padding: 5rpx 20rpx 32rpx 46rpx;
	position: relative;
	color: #333333;
	line-height: 44rpx;
	position: relative;

	.guidelines {
		width: 90%;
		display: flex;
		margin: 10rpx 0;

		&-item {
			font-size: 28rpx;
			color: #666;
			display: flex;
			background: #edf2f6;
			border-radius: 4rpx;
			padding: 2rpx 5rpx;
			display: flex;
			align-items: center;

			image {
				width: 24rpx;
				height: 24rpx;
				margin: 0 5rpx;
			}

			&-name {
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
				-o-text-overflow: ellipsis;
			}
		}
	}

	.edit {
		position: absolute;
		z-index: 10;
		top: 10rpx;
		right: 10rpx;

		image {
			width: 35rpx;
			height: 35rpx;
		}

		font-size: 26rpx;
		color: #0091ff;
		display: flex;
		align-items: center;
	}

	.num {
		width: 40rpx;
		height: 40rpx;
		// background: #ddf0ff;
		border-radius: 0rpx 4rpx 4rpx 0rpx;
		position: absolute;
		left: 0;
		top: 6rpx;
		font-size: 26rpx;
		text-align: right;
		color: red;
		line-height: 40rpx;
	}

	&-title {
		font-size: 28rpx;
		// font-weight: bold;
		width: 80%;
		position: relative;
		// height: 30rpx;
	}

	.hide-btn {
		font-size: 28rpx;
		color: #0091ff;
		position: absolute;
		right: -24%;
		top: -1rpx;
	}

	&-introduce {
		font-size: 24rpx;
		color: #999999;
	}

	.record-detail {
		position: relative;
	}

	.content-item {
		position: relative;

		.name {
			font-size: 26rpx;
			color: #666;
			padding: 8rpx 0;

			text {
				color: red;
			}
		}

		.files {
			width: calc(100% + 50rpx);
			display: flex;
			flex-wrap: wrap;
			margin-left: -10rpx;

			&-item {
				width: 112rpx;
				height: 112rpx;
				background: #f7f7f8;
				margin: 10rpx;
				position: relative;

				image {
					width: 100%;
					height: 100%;
				}

				.remove {
					width: 32rpx;
					height: 32rpx;
					background: #cccccc;
					border-radius: 50%;
					line-height: 31rpx;
					text-align: center;
					color: #fff;
					// font-size: 41rpx;
					position: absolute;
					top: -12rpx;
					right: -12rpx;
					z-index: 7;
					display: flex;
					align-items: center;
					justify-content: center;
				}

				.ai-result {
					position: absolute;
					bottom: 0;
					left: 0;
					display: flex;
					align-items: center;
					justify-content: center;
					text-align: center;
					width: 112rpx;
					height: 32rpx;
					color: #fff;
					font-size: 22rpx;
					padding: 0;
					vertical-align: unset;
					font-weight: normal;

					&-ico {
						width: 21rpx;
						height: 21rpx;
						margin-right: 4rpx;
					}
				}

				.gre {
					background-color: #68CA00;
				}

				.org {
					background-color: #FF7505;
				}

				.red {
					background-color: #E02020;
				}
			}

			.add {
				text-align: center;
				font-size: 24rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				color: #0091ff;
				line-height: 14rpx;

				image {
					width: 45rpx;
					height: 45rpx;
				}
			}
		}

		.input {
			color: #333;

			.text {
				display: flex;
				align-items: center;

				input {
					width: 260rpx;
					padding: 10rpx 20rpx;
					border: 2rpx solid #e9e9e9;
					margin-right: 20rpx;
				}
			}

			text {
				color: #ccc;
				word-wrap: normal;
			}

			.input-view {
				width: 100%;
				display: flex;
				align-items: center;

				input {
					flex: 1;
					padding: 10rpx 20rpx;
					border: 2rpx solid #e9e9e9;
					margin-right: 10rpx;
					font-size: 26rpx;
				}

				.input-unit {
					width: 57%;
				}

				text {
					color: #333;
				}
			}

			textarea {
				width: calc(100% - 42rpx);
				border: 1rpx solid #e9e9e9;
				padding: 20rpx;
				height: 180rpx;
				padding-bottom: 50rpx;
			}

			.length {
				bottom: 10rpx;
				z-index: 9;
				position: absolute;
				right: 27rpx;
				font-size: 24rpx;
				color: #ccc;
			}
		}
	}

	.content-logsTitle {
		font-size: 24rpx;
		font-weight: bold;
		padding: 10rpx 0rpx;
	}

	.content-logs {
		background: #edf2f6;
		padding: 10rpx 20rpx;
		border-radius: 4rpx;
		color: #333;
		font-size: 24rpx;
		margin-left: 36rpx;

		.title {
			font-weight: bold;
		}

		.logs_box {
			display: flex;
			align-items: top;

			.label {
				color: #666;
				// margin-right: 20rpx;
				width: 72rpx;
			}

			.msg {
				flex: 1;
			}
		}

		&-plan {
			margin-bottom: 10rpx;
			position: relative;

			&-title {
				font-size: 24rpx;
				font-weight: bold;
			}

			&-view {
				position: absolute;
				color: #0091ff;
				font-size: 24rpx;
				padding: 10rpx;
				right: 8rpx;
				// top:42rpx;
				top: 0rpx;
				z-index: 10
			}

			&-card {
				background: #fff;
				padding: 8rpx 10rpx;
				color: #333;

				.clpc-item {
					display: flex;
					font-size: 24rpx;
					align-items: center;
					justify-content: flex-start;

					&-label {
						padding-right: 18rpx;
						color: #999;

					}

					&-content {
						.tag {
							color: #ffffff;
							padding: 0 4rpx;
							margin-left: 8rpx;
							background: #0091ff;
							font-size: 22rpx;
							border-radius: 4rpx;
						}
					}
				}
			}
		}

	}

	.line {
		width: 100%;
		height: 2rpx;
		background-color: #eeeeee;
		margin-top: 20rpx;
	}
}

// 正常异常选项列表
.tag-list {
	width: 100%;
	display: flex;
	margin: 14rpx 0;

	.tag-item {
		width: 180rpx;
		height: 48rpx;
		border: 2rpx solid #e9e9e9;
		border-radius: 8rpx;
		line-height: 48rpx;
		margin-right: 20rpx;
		padding: 0 10rpx;
		transition: 0.3s all;
	}

	.tag-item:last-child {
		margin-right: 0rpx;
	}
}

.record-add-btn {
	display: flex;
	align-items: center;
	color: #0091ff;
	font-size: 28rpx;
}

.success {
	color: #6bc013 !important;
	border: 2rpx solid #6bc013 !important;
}

.danger {
	color: #e02020 !important;
	border-color: #e02020 !important;
}

.routine {
	color: #f7b500 !important;
	border-color: #f7b500 !important;
}

.error-border {
	border: 1px dashed #e02020 !important;
}

.indent {
	// padding-left: 36rpx;
}
</style>
